package com.addplus.townmall.server.api.mapper.town;

import com.addplus.townmall.server.api.model.town.ShopMemberShopCart;
import com.addplus.townmall.server.api.model.town.expand.ShopMemberShopCartExpand;
import com.addplus.townmall.server.api.utils.BaseAddMapper;
import org.apache.ibatis.annotations.MapKey;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

/**
 * <p>
 * 商城会员购物车 Mapper 接口
 * </p>
 *
 * @author zhangjiehang
 * @since 2018-10-24
 */
public interface ShopMemberShopCartMapper extends BaseAddMapper<ShopMemberShopCart> {

    @Select("<script> " +
            "SELECT " +
            " c.id, " +
            " c.shop_id, " +
            " c.shop_sku_id, " +
            " c.quantity, " +
            " c.price, " +
            " c.store_id, " +
            " s.shop_name, " +
            " s.shop_seal_img, " +
            " sku.sale_price, " +
            " sku.sku_describe " +
            "FROM\n" +
            " shop_member_shop_cart c " +
            " LEFT JOIN shop_product s ON s.id = c.shop_id  " +
            " AND s.is_deleted = 0  " +
            " AND s.sale_status = 0 " +
            " LEFT JOIN shop_specification_sku sku ON sku.id = c.shop_sku_id AND sku.is_deleted = 0 " +
            " WHERE c.member_id = #{memberId} AND c.store_id in " +
            "<foreach collection='storeIdList' open='('  item='item'  separator=',' close=')'> #{item}</foreach>" +
            " and c.is_delete = 0  " +
            " ORDER BY c.gmt_modified DESC" +
            "</script>")
    List<ShopMemberShopCartExpand> getShopMemberShopCartByStoreList(@Param("memberId") Integer memberId, @Param("storeIdList") List<Integer> storeIdList);
}
